<%@page import="com.jfinal.kit.PropKit" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" import="cn.com.dashihui.web.common.OrderCode" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <title>会员管理</title>
    <jsp:include page="../../include/header.jsp"></jsp:include>
    <style type="text/css">
			table th{
						text-align: center;
			        }
			table td{
						text-align: center;
			        }
			  table{
			         empty-cells:show; 
			         border-collapse: collapse;
			         margin:0 auto;
			        }
 			.col-lg-9 {
			    width: 100%;
			}
			.pcc{
				width: 110px;
				height: 34px;
			}
			input{
				text-indent:10px;
				border-radius:5px;
			}
		</style>
</head>
<body>
<div id="wrapper" class="row">
	<div >
		<div class="col-lg-12">
			<h1 class="page-header">积分统计</h1>
		</div>
	</div>
	<!-- 搜索框 -->

		<div class="col-lg-offset col-lg-9">
			<label class="search-label">会员手机号：</label><input type="text" id="sPhone" value="" placeholder="手机号" class="form-control search-input width200" maxlength="21">
			<label class="search-label">会员卡号：</label><input type="text" id="sCard" value="" placeholder="请输入会员卡号" class="form-control search-input width200" maxlength="21">
			<label class="search-label">分公司：</label>
				<select id="sStore" class="selectpicker pull-left p-l-5"  data-width="12%" <c:if test="${RoleId == 3 || RoleId == 4}">disabled="disabled"</c:if>>
					<option value="">请选择分公司</option>
					<c:forEach items="${storeList }" var="seller">
						<option value="${seller.storeid }">${seller.title }</option>
					</c:forEach>
				</select>
			 <button class="btn btn-success search-btn" onclick="query();">确定</button>
			<button class="btn btn-success search-btn" onclick="reset();">重置</button>
			<c:if test="${session.userpopedom.busUserVipindexDoExcel==1}">
					<button onclick="doExcel();"class="btn btn-success pull-right"  >导出</button>
				</c:if>
		</div>

		<div class="clearfix"></div>
		<div class="col-lg-12">
			<div class="row">
				<div class="text-muted single-line-text pull-left">共 <font color="#428bca" id="dataCount">0</font> 条记录</div>
				<div style="float:left;margin-right: 30px;">
					<div class="text-muted single-line-text pull-right"> 
						<input type="radio" class="radioItem" id="state1" name="state" value="1" />
						<label>积分</label>
						<input type="radio" class="radioItem" id="state2" name="state" value="2" />
						<label>抵扣券</label>
						<input type="radio" class="radioItem" id="state3" name="state" value="3" />
						<label> 惠券</label>
					  </div>
				</div>
				
				<div class="clearfix"></div>
			</div>
			<div class="table-responsive panel panel-default" >
				<table id="dataTable" class="table table-hover table-bordered" style="overflow:scroll;">
		            <thead>
		               	<tr>
							<th width="200px;">会员卡号</th>
							<th width="100px;">会员姓名</th>
							<th width="200px;">会员手机号</th>
							<th width="200px;">所属分公司</th>
							<th width="150px;">办卡日期</th>
							<th width="100px;">积分</th>
							<th width="100px;">抵扣券</th>
							<th width="100px;">惠券</th>
							<th width="100px;">积分明细</th>
						</tr>
		            </thead>
		            <tbody id="dataList"></tbody>
		        </table>
			</div>
	        <div class="row">
	        	<div class="col-lg-12">
	        		<ul id="dataPagination" class="pagination-sm pull-right"></ul>
	        	</div>
	        </div>
		</div>
	
</div>
<jsp:include page="../../include/javascripts.jsp"></jsp:include>
<!-- 异步加载下一页数据后，用模板渲染 -->
<script type="text/html" id="dataTpl">
		{{each list as item}}
				 <tr id="item{{item.id}}" data-id="{{item.id}}">
				 	<td>
						<a href="javascript:showDetail('{{item.id}}');">
							<font color="#40a9ff" id="dataCount">
								{{if item.card}}{{item.card }}{{/if}}
								{{if !item.card}}--{{/if}}
							</font>
						</a>
					</td>
					<td>
						{{if item.taici==7}}<font color="#428bca" >{{item.name }}</font>{{/if}}
						{{if item.taici!=7}}{{item.name}}{{/if}}
					</td>
					<td>{{item.phone}}</td>
					<td>
						{{if item.toBossTwoId}}{{item.storeName }}{{/if}}
						{{if !item.toBossTwoId}}--{{/if}}
					</td>
					<td>{{item.createDate}}</td>
					<td>{{item.sppoint}}</td>
					<td>{{item.jkpoint}}</td>
					<td>{{item.jypoint}}</td>
					<td>
						<a href="javascript:showUser('{{item.id}}');"><span class="btn">积分明细</span></a>
					</td>
				</tr>
		{{/each}}
</script>
<script type="text/javascript">
var dataPaginator;
$(query);
function query(){
	 var phone=$("#sPhone").val(),card=$("#sCard").val(),store=$("#sStore").val();
	 var params = {
		pageSize:10,
		phone:phone,
		card:card,
		store:store
	};
	if(dataPaginator){
		dataPaginator.destroy();
	}
	dataPaginator = Kit.pagination("#dataPagination","${BASE_PATH}/bus/user/vippage",params,function(result){
		//设置显示最新的数据数量
		$("#dataCount").html(result.object.totalRow);
		//根据模板渲染数据并填充
		$("#dataList").empty().append(template("dataTpl",result.object));
	});
}
$(document).ready(function() {
    $(".radioItem").change(function() {
    	 var $selectedvalue = $("input[name='state']:checked").val();
    	var params = {
    			pageSize:10,
    			pageSize:10,
    			phone:$("#sPhone").val(),
    			card:$("#sCard").val(),
    			store:$("#sStore").val(),
    			date:$selectedvalue
    		};
    		if(dataPaginator){
    			dataPaginator.destroy();
    		}
    		dataPaginator = Kit.pagination("#dataPagination","${BASE_PATH}/bus/user/vipsjj",params,function(result){
    			//设置显示最新的数据数量
    			$("#dataCount").html(result.object.totalRow);
    			//根据模板渲染数据并填充
    			$("#dataList").empty().append(template("dataTpl",result.object));
    		});
    });
});
function reset(){
	$("#sPhone").val("");$("#sCard").val("");$("#sStore").val("");$("#sStore").trigger("change");
}
var showDialog;//closable:true,size:'size-wide'
function showUser(id){
	showDialog = Kit.dialog("会员积分明细","${BASE_PATH}/bus/user/detailVip/"+id,{size:'size-wide',closable:true}).open();
}
var showDetailDialog;
function showDetail(id){
	showDetailDialog = Kit.dialog("会员详情信息","${BASE_PATH}/bus/user/detail/"+id,{size:'size-wide',closable:true}).open();
}
function onEditSuccess(newObject){
	$("#item"+newObject.id).replaceWith(template("dataTpl",{"list":[newObject]}));
}
function doExcel(){
	 var phone=$("#sPhone").val(),card=$("#sCard").val(),store=$("#sStore").val();
	window.location.href="${BASE_PATH}/bus/user/doVipExcel?phone="+phone+"&card="+card+"&store="+store;
}
 
 
</script>
</body>
</html>